import { ProjectCollaborationData } from "@type";
import Api from "./Api";
import { Page } from "antd-mobile/es/components/calendar/convert";
//接口模版
class ProjectCollaborationApi extends Api {
  constructor() {
    super();
  }

  //添加
  add(name: string, description: string) {
    return this._post("/customer/project/add", { name, description });
  }
  //修改
  update(data: Partial<ProjectCollaborationData>) {
    return this._post("/customer/project/update", data);
  }
  //删除
  delete(id: string) {
    return this._post(`/customer/project/delete/${id}`);
  }
  //退出项目
  exit(id: string) {
    return this._post(`/customer/project/member/exit/${id}`);
  }
  // 删除成员
  deleteJoiner(id: string) {
    return this._post(`/customer/project/member/delete/${id}`);
  }
  //查询成员列表
  getJoinerList(pageNum: number, pageSize: number, projectId: string) {
    return this._post("/customer/project/member/list", {
      pageNum,
      pageSize,
      data: {
        projectId,
      },
    });
  }
  //查询项目列表
  get(
    pageNum: number,
    pageSize: number,
    data?: {
      shared: boolean; // 是否查询参与的项目
      status: 0 | 1; //，0为未完成，1为已完成
    }
  ) {
    return this._post("/customer/project/list", {
      pageNum,
      pageSize,
      data,
    });
  }
  //获取单个项目的信息
  get_by_id(id: string) {
    return this._post(`/customer/project/get/${id}`);
  }
  //获取项目分享链接
  get_project_shareLink(projectId: string) {
    return this._post(`/customer/project/shareLink/get/${projectId}`);
  }
  //开关项目的分享链接
  updateStatus_project_shareLink(projectId: string, status: number) {
    return this._post(
      `/customer/project/shareLink/updateStatus/${projectId}?status=${status}`
    );
  }
  //访问分享链接
  add_project_shareLink(shareId: string) {
    return this._post(`/customer/project/shareLink/add/member/${shareId}`);
  }
}
const projectCollaborationApi = new ProjectCollaborationApi();
export default projectCollaborationApi;
